package com.zlkj.pro.modular.business.task;

import com.zlkj.pro.modular.business.service.TaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Slf4j
@Component
public class DailyTask {

    @Autowired
    private TaskService taskService;

    @Scheduled(cron = "0 0 7 * * ?")
    public void dailyAtTwentyMinutesPastMidnight() {
        LocalDateTime now = LocalDateTime.now();
        log.info("Daily task executed at: {}", now);
        String message = taskService.sendTodayNotice();
        log.info("Daily task executed done: {}", message);
    }


    //每年1月1日0点执行 重置书名号编码
    @Scheduled(cron = "0 0 0 1 1 ?")
    public void resetCerNumber() {
        LocalDateTime now = LocalDateTime.now();
        log.info("Daily task resetCerNumber executed at: {}", now);
        taskService.resetCerNumber();
        log.info("Daily task resetCerNumber executed done: {}", now);
    }

}
